#include<stdio.h>
struct student {
	int high;
	int year;
};
int main()
{
	int n=0;
	scanf("%d",&n);
	struct student arr[n];
	int count1=0,count2=0;
	for(int i=0;i<n;i++)
	{
		scanf("%d%d",&arr[i].high,&arr[i].year);
	}
	for(int i=1;i<n-1;i++)
	{
		if(arr[i].high>arr[i-1].high&&arr[i].high>arr[i+1].high)
		{
			count1++;
		}
		else if (arr[i].year>arr[i-1].year&&arr[i].year>arr[i+1].year)
		{
			count2++;
		}
	}
	int result=0;
	result=(count1>=count2)?count2:count1;
	printf("%d",result);
}
